From: Florian Müllner Date: Sat, 29 Jun 2019 23:02:34 +0000 (+0200) Subject: ibusManager: Use Map to store engines X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~845^2^2~71 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=e95f3febd6398fa56d363a1e13bc17af3de1f5d1;p=gnome-shell.git ibusManager: Use Map to store engines This is a clear case of key->value mapping, so using the corresponding data type makes sense. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/612 --- diff --git a/js/misc/ibusManager.js b/js/misc/ibusManager.js index 338542a13..5a0d2906a 100644 --- a/js/misc/ibusManager.js +++ b/js/misc/ibusManager.js @@ -42,7 +42,7 @@ var IBusManager = class { this._candidatePopup = new IBusCandidatePopup.CandidatePopup(); this._panelService = null; - this._engines = {}; + this._engines = new Map(); this._ready = false; this._registerPropertiesId = 0; this._currentEngineName = null; @@ -73,7 +73,7 @@ var IBusManager = class { this._panelService = null; this._candidatePopup.setPanelService(null); - this._engines = {}; + this._engines.clear(); this._ready = false; this._registerPropertiesId = 0; this._currentEngineName = null; @@ -96,7 +96,7 @@ var IBusManager = class { if (enginesList) { for (let i = 0; i < enginesList.length; ++i) { let name = enginesList[i].get_name(); - this._engines[name] = enginesList[i]; + this._engines.set(name, enginesList[i]); } this._updateReadiness(); } else { @@ -150,8 +150,7 @@ var IBusManager = class { } _updateReadiness() { - this._ready = (Object.keys(this._engines).length > 0 && - this._panelService != null); + this._ready = this._engines.size > 0 && this._panelService != null; this.emit('ready', this._ready); } @@ -189,10 +188,10 @@ var IBusManager = class { } getEngineDesc(id) { - if (!this._ready || !this._engines.hasOwnProperty(id)) + if (!this._ready || !this._engines.has(id)) return null; - return this._engines[id]; + return this._engines.get(id); } setEngine(id, callback) {